package com.rs.game.player.dialogues.impl;

import com.rs.game.World;
import com.rs.game.player.Player;
import com.rs.game.player.dialogues.Dialogue;
import com.rs.utils.SerializableFilesManager;
import com.rs.utils.Utils;

public class ModPanel extends Dialogue {
	
	Player target;

	@Override
	public void start() {
		target = (Player) parameters[0];
		sendOptionsDialogue("Player Options", "<col=FF0000>Ban</col> " + target.getDisplayName() + " permanently.", "<col=FF0000>Mute</col> " + target.getDisplayName() + " for 48 hours.", "<col=FF0000>Kick</col> " + target.getDisplayName() + ".", "<col=FF0000>Jail</col> " + target.getDisplayName() + " for 24 hours.", "<col=FF0000>Cancel</col>");
	}

	@Override
	public void run(int interfaceId, int componentId) {
		switch (stage) {
		case -1:
			switch (componentId) {
			case OPTION_1:
				if (target.getRights() == 2) {
					return;
				}
				target.setPermBanned(true);
				target.getSession().getChannel().close();
				SerializableFilesManager.savePlayer(target);
				World.sendWorldMessage("<col=FF0000>" + player.getDisplayName() + " has permanently banned " + target.getDisplayName() + ".</col>", false);
				stage = 0;
				break;
			case OPTION_2:
				if (target.getRights() == 2) {
					return;
				}
				target.setBlackmarks(target.getBlackmarks() + 0.5);
				target.setMuted(Utils.currentTimeMillis() + (player.getRights() >= 1 ? (48 * 60 * 60 * 1000) : (1 * 60 * 60 * 1000)));
				target.getPackets().sendGameMessage("You've been muted for " + (player.getRights() >= 1 ? "48 hours by " : "1 hour by ") + Utils.formatPlayerNameForDisplay(player.getUsername()) + ".");
				player.getPackets().sendGameMessage("You have muted " + target.getDisplayName() + (player.getRights() >= 1 ? "for 48 hours. " : "for 1 hour. "));
				stage = 0;
				break;
			case OPTION_3:
				if (target.getRights() == 2) {
					return;
				}
				target.getSession().getChannel().close();
				player.getPackets().sendGameMessage("You have kicked: " + target.getDisplayName() + ".");
				stage = 0;
				break;
			case OPTION_4:
				if (target.getRights() == 2) {
					return;
				}
				target.setJailed(Utils.currentTimeMillis() + (24 * 60 * 60 * 1000));
				target.getControlerManager().startControler("JailControler");
				target.getPackets().sendGameMessage("You've been Jailed for 24 hours by " + Utils.formatPlayerNameForDisplay(player.getUsername()) + ".");
				player.getPackets().sendGameMessage("You have Jailed 24 hours: " + target.getDisplayName() + ".");
				stage = 0;
				break;
			case OPTION_5:
				end();
				break;
			}
		case 0:
			end();
			break;
		}
	}

	@Override
	public void finish() {
		// TODO Auto-generated method stub
		
	}
}


